package kr.nexmore.slmsample2.dao;

import java.util.List;

import kr.nexmore.slmsample2.util.MyBatisConnectionFactory;
import kr.nexmore.slmsample2.vo.BoardVo;

import org.apache.ibatis.session.SqlSession;

public class MyBoardDao {

	public List<BoardVo> select() {

		List<BoardVo> result = null;

		SqlSession session = MyBatisConnectionFactory.openSession();

		result = session.selectList("Board.getListBoard");

		for (BoardVo h : result)
			System.out.println(h.getName());

		session.close();

		return result;
	}

	public void insert(BoardVo vo) {
		SqlSession session = MyBatisConnectionFactory.openSession();

		session.insert("Board.insertBoard", vo);

		session.commit();

		session.close();

	}

	public void update(BoardVo vo) {
		SqlSession session = MyBatisConnectionFactory.openSession();

		session.update("Board.updateBoard", vo);

		session.commit();

		session.close();

	}

	public void delete(BoardVo vo) {
		SqlSession session = MyBatisConnectionFactory.openSession();

		session.delete("Board.deleteBoard", vo);

		session.commit();

		session.close();
	}

}
